﻿Imports System.Collections.Generic
Imports System.Data.SqlClient
Imports Bussines.entity
Public Class acuerdosDAL
    Dim cnn As New conexion

    Public Function insertarAcuerdos(ByVal BE As List(Of acuerdosBE)) As String


        Dim cont As Integer
        'Dim trx As SqlTransaction


        'trx = cnn.abrir().BeginTransaction()
        
        Try
            For cont = 0 To BE.Count
                Dim cmd As New SqlCommand
                cmd.Connection = cnn.abrir()
                cmd.CommandType = CommandType.StoredProcedure
                cmd.CommandText = "sp_insertarAcuerdos"
                'cmd.Transaction = trx

                Dim AcuerdoBE As New acuerdosBE
                AcuerdoBE = BE.Item(cont)
                cmd.Parameters.Add(New SqlParameter("@idActa", SqlDbType.Int)).Value = AcuerdoBE.idActa
                cmd.Parameters.Add(New SqlParameter("@detalle_acuerdo", SqlDbType.VarChar, -1)).Value = AcuerdoBE.detalle_acuerdo
                cmd.Parameters.Add(New SqlParameter("@Plazo", SqlDbType.VarChar)).Value = AcuerdoBE.Plazo
                cmd.Parameters.Add(New SqlParameter("@responsable", SqlDbType.VarChar)).Value = AcuerdoBE.responsable
                cmd.ExecuteNonQuery()
                cmd.Dispose()
            Next
            'trx.Commit()
            Return "1"
        Catch ex As Exception
            'trx.Rollback()
            Return ex.Message
        Finally

            cnn.Cerrar()
        End Try

    End Function
End Class
